<?php
//           当前页码,固定显示条数,总记录数,总页码数
function page($curpage,$perpage,$count,$numpage){

	$page='';
	$front=$curpage-2;
	$back=$curpage+2;
	if($front<1){
		$front==1;
		$back=5;
		};
	if($back>=$numpage){
		$back=$numpage;
		$front=$numpage-4;
		};
		   if(ADMIN=='admin'){$admin='admin=1';};
		   if(ADMIN=='home'){$admin='admin=0';};
	if($curpage>1){
	$first=1;
	$page.='<li class="first"><a href="index.php?'.$admin.'&c='.$_GET['c'].'&a=list&p='.$first.'">&nbsp;首页&nbsp;</a></li>';
	$up=$curpage-1;
	$page.='<li class="upPage"><a href="index.php?'.$admin.'&c='.$_GET['c'].'&a=list&p='.$up.'">&nbsp;上一页&nbsp;</a></li>';
	};
	for($i=$front;$i<=$back;$i++){
		if($i<1){$i=1;};
		if($curpage==$i){$curt=' style="background:#09F"';}else{$curt='';};
		$page.='<li'.$curt.'><a href="index.php?'.$admin.'&c='.$_GET['c'].'&a=list&p='.$i.'">&nbsp;'.$i.'&nbsp;</a></li>' ; 
	};
	if($curpage<$numpage){
	$next=$curpage+1;
	$page.='<li class="upPage"><a href="index.php?'.$admin.'&c='.$_GET['c'].'&a=list&p='.$next.'">&nbsp;下一页&nbsp;</a></li>';
	$last=$numpage;
	$page.='<li class="lastPage"><a href="index.php?'.$admin.'&c='.$_GET['c'].'&a=list&p='.$last.'">&nbsp;末页&nbsp;</a></li>';
	};
	$page.='&nbsp;<input type="text" name="sum" style="width:25px;height:21px"/>'.'&nbsp;<input type="submit" name="jump" value="跳转"/>';

	if(!empty($_POST)){
		$sum=$_POST['sum'];
		if($sum>$numpage){$sum=$numpage;};
		if($sum<1){$sum=1;};
		echo '<script>location="index.php?'.$admin.'&c='.C.'&a=list&p='.$sum.'";</script>';
	};
	return $page;
};
?>